package demo_0512;

import javax.swing.*;
import java.awt.*;

import static javax.swing.WindowConstants.EXIT_ON_CLOSE;

public class DrawDemo extends JPanel {
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        g.setColor(new Color(0, 64, 255, 255));
        g.drawLine( 0,0,200,200);
        g.drawString( "你好", 200,200);
        //g.drawImage( new ImageIcon("E:\\vs背景\\dd4aee16880411ebb6edd017c2d2eca2.jpg").getImage(), 0,0, 600,600, this);
        g.drawArc( 100,100, 200,200, 0, 90);  //画扇形
        g.drawOval( 100,100, 200,200);  //画椭圆
        g.drawRect( 100,100, 200,200);  //画矩形
        g.drawRoundRect( 100,100, 200,200, 50,50);  //画圆角矩形
        g.fillArc( 100,100, 200,200, 0, 90);  //填充扇形

    }

    public static void main(String[] args) {
        JFrame frame = new JFrame("我的画图");
        frame.setBounds(200,200, 1000,1000);
        frame.setVisible(true);
        DrawDemo drawDemo  = new DrawDemo();
        frame.add(drawDemo);
        frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
    }
}
